package com.dha.adapter;

import java.util.ArrayList;

import com.dha.caodangcongnghe.R;
import com.dha.model.DiemModel;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebView.FindListener;
import android.widget.ArrayAdapter;
import android.widget.CheckBox;
import android.widget.TextView;

public class XemDiemAdapter extends ArrayAdapter<DiemModel> {
	private Context context;
	private ArrayList<DiemModel> arr;
	private int layoutId;
	
	public XemDiemAdapter(Context context, int resource, ArrayList<DiemModel> objects) {
		super(context, resource, objects);
		// TODO Auto-generated constructor stub
		this.context = context;
		layoutId = resource;
		arr = objects;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		LayoutInflater inflater = (LayoutInflater) context.getSystemService(context.LAYOUT_INFLATER_SERVICE);
		convertView = inflater.inflate(layoutId, parent, false);
		
		TextView tv_custom_xemDiem_tenHocPhan = (TextView) convertView
				.findViewById(R.id.tv_custom_xemDiem_tenHocPhan);
		
		TextView tv_custom_xemDiem_diemTongKet = (TextView) convertView
				.findViewById(R.id.tv_custom_xemDiem_diemTongKet);
		
		TextView tv_custom_xemDiem_diemChu = (TextView) convertView
				.findViewById(R.id.tv_custom_xemDiem_diemChu);
		
		TextView tv_custom_xemDiem_soTC = (TextView) convertView
				.findViewById(R.id.tv_custom_xemDiem_soTC);
		
		TextView tv_custom_xemDiem_hocKy = (TextView) convertView
				.findViewById(R.id.tv_custom_xemDiem_hocKy);
		
		TextView tv_custom_xemDiem_maHocPhan = (TextView) convertView
				.findViewById(R.id.tv_custom_xemDiem_maHocPhan);
		
		TextView tv_custom_xemDiem_lopHocPhan = (TextView) convertView
				.findViewById(R.id.tv_custom_xemDiem_lopHocPhan);
		
		
		CheckBox cb_custom_xemDiem_tichLuy = (CheckBox) convertView
				.findViewById(R.id.cb_custom_xemDiem_tichLuy);
		
		tv_custom_xemDiem_tenHocPhan.setText(arr.get(position).getTenHP());
		tv_custom_xemDiem_diemTongKet.setText(arr.get(position).getDiemTK());
		tv_custom_xemDiem_diemChu.setText(arr.get(position).getDiemChu());
		tv_custom_xemDiem_soTC.setText(arr.get(position).getSoTinChi());
		tv_custom_xemDiem_hocKy.setText(arr.get(position).getHocKy());
		tv_custom_xemDiem_maHocPhan.setText(arr.get(position).getMaHP());
		tv_custom_xemDiem_lopHocPhan.setText(arr.get(position).getLopHP());
		
		if (arr.get(position).isTichLuy()){
			cb_custom_xemDiem_tichLuy.setChecked(true);
		}else{
			cb_custom_xemDiem_tichLuy.setChecked(false);
		}
		
		return convertView;
	}
	
	

}
